using System;
using System.Globalization;
using System.Resources;
using System.Threading;

namespace Demo
{
    public enum Language
    {
        SimplifiedChinese,  // 简体中文
        TraditionalChinese  // 繁体中文
    }

    public static class LanguageHelper
    {
        private static Language currentLanguage = Language.SimplifiedChinese;

        public static Language CurrentLanguage
        {
            get => currentLanguage;
            set
            {
                currentLanguage = value;
                OnLanguageChanged?.Invoke();
            }
        }

        public static event Action? OnLanguageChanged;

        public static string GetString(string key)
        {
            return currentLanguage switch
            {
                Language.SimplifiedChinese => GetSimplifiedString(key),
                Language.TraditionalChinese => GetTraditionalString(key),
                _ => key
            };
        }

        private static string GetSimplifiedString(string key)
        {
            return key switch
            {
                "Login" => "登录",
                "Username" => "账号",
                "Password" => "密码",
                "RememberPassword" => "记住密码",
                "Language" => "语言",
                "SimplifiedChinese" => "简体中文",
                "TraditionalChinese" => "繁体中文",
                "SystemLogin" => "系统登录",
                "PleaseEnterUsername" => "请输入账号",
                "PleaseEnterPassword" => "请输入密码",
                "LoginSuccess" => "登录成功",
                "DataManagement" => "数据管理",
                "ParameterNumber" => "参数编号",
                "MainTesterName" => "主试名字",
                "ChildName" => "儿童名字",
                "TestDate" => "测试日期",
                "BirthDate" => "出生日期",
                "Grade" => "所在年级",
                "ParentEducation" => "家长教育程度",
                "PhoneNumber" => "电话号码",
                "Email" => "电子邮箱",
                "Address" => "联系地址",
                "Remarks" => "备注资料",
                "ChildGender" => "儿童性别",
                "HandPreference" => "用手习惯",
                "Male" => "男性",
                "Female" => "女性",
                "RightHand" => "右手",
                "LeftHand" => "左手",
                "Uncertain" => "不确定",
                "Blocks" => "积木",
                "Comprehension" => "常识",
                "MatrixReasoning" => "矩阵推理",
                "BugSearch" => "找虫",
                "PictureMemory" => "图片记忆",
                "Similarities" => "类同",
                "PictureConcepts" => "图书概念",
                "Cancellation" => "画消",
                "AnimalHome" => "动物家园",
                "Puzzle" => "拼图",
                "AnimalCoding" => "动物译码",
                "Understanding" => "理解",
                "PictureRecognition" => "指认图片",
                "PictureNaming" => "图片命名",
                "RandomCancellation" => "随机画消",
                "OrderedCancellation" => "有序画消",
                "ConfidenceLevel" => "信赖水平",
                "StatisticalSignificance" => "统计显著性水准",
                "ComparisonBasis" => "比较基础",
                "CalculationMethod" => "计算方法",
                "SubstitutionScoreTest" => "替代分检验",
                "ProportionEstimation" => "比例估算法",
                "ReportPassword" => "为报告添加密码",
                "ReEnter" => "重新录入",
                "GenerateReport" => "生成报告",
                "Add" => "添加",
                "Edit" => "编辑",
                "Delete" => "删除",
                "Save" => "保存",
                "Cancel" => "取消",
                "Search" => "搜索",
                "Required" => "必填",
                "95Percent" => "95%",
                "90Percent" => "90%",
                "FullSample" => "全样本",
                "SelectGrade" => "请选择年级",
                "SelectEducation" => "请选择教育程度",
                _ => key
            };
        }

        private static string GetTraditionalString(string key)
        {
            return key switch
            {
                "Login" => "登入",
                "Username" => "帳號",
                "Password" => "密碼",
                "RememberPassword" => "記住密碼",
                "Language" => "語言",
                "SimplifiedChinese" => "簡體中文",
                "TraditionalChinese" => "繁體中文",
                "SystemLogin" => "系統登入",
                "PleaseEnterUsername" => "請輸入帳號",
                "PleaseEnterPassword" => "請輸入密碼",
                "LoginSuccess" => "登入成功",
                "DataManagement" => "資料管理",
                "ParameterNumber" => "參數編號",
                "MainTesterName" => "主試名字",
                "ChildName" => "兒童名字",
                "TestDate" => "測試日期",
                "BirthDate" => "出生日期",
                "Grade" => "所在年級",
                "ParentEducation" => "家長教育程度",
                "PhoneNumber" => "電話號碼",
                "Email" => "電子郵箱",
                "Address" => "聯繫地址",
                "Remarks" => "備註資料",
                "ChildGender" => "兒童性別",
                "HandPreference" => "用手習慣",
                "Male" => "男性",
                "Female" => "女性",
                "RightHand" => "右手",
                "LeftHand" => "左手",
                "Uncertain" => "不確定",
                "Blocks" => "積木",
                "Comprehension" => "常識",
                "MatrixReasoning" => "矩陣推理",
                "BugSearch" => "找蟲",
                "PictureMemory" => "圖片記憶",
                "Similarities" => "類同",
                "PictureConcepts" => "圖書概念",
                "Cancellation" => "畫消",
                "AnimalHome" => "動物家園",
                "Puzzle" => "拼圖",
                "AnimalCoding" => "動物譯碼",
                "Understanding" => "理解",
                "PictureRecognition" => "指認圖片",
                "PictureNaming" => "圖片命名",
                "RandomCancellation" => "隨機畫消",
                "OrderedCancellation" => "有序畫消",
                "ConfidenceLevel" => "信賴水準",
                "StatisticalSignificance" => "統計顯著性水準",
                "ComparisonBasis" => "比較基礎",
                "CalculationMethod" => "計算方法",
                "SubstitutionScoreTest" => "替代分檢驗",
                "ProportionEstimation" => "比例估算法",
                "ReportPassword" => "為報告添加密碼",
                "ReEnter" => "重新錄入",
                "GenerateReport" => "生成報告",
                "Add" => "添加",
                "Edit" => "編輯",
                "Delete" => "刪除",
                "Save" => "保存",
                "Cancel" => "取消",
                "Search" => "搜索",
                "Required" => "必填",
                "95Percent" => "95%",
                "90Percent" => "90%",
                "FullSample" => "全樣本",
                "SelectGrade" => "請選擇年級",
                "SelectEducation" => "請選擇教育程度",
                _ => key
            };
        }
    }
}

